package com.ihr360.oneclick.modal;

import com.ihr360.oneclick.entity.IdCardType;
import com.ihr360.oneclick.entity.OneClickTerm;
import com.ihr360.oneclick.entity.RowHeaderColumn;
import com.ihr360.oneclick.entity.SpreadSheetRowHeader;
import com.ihr360.oneclick.entity.Spreadsheet;
import com.ihr360.oneclick.entity.SpreadsheetRow;
import com.ihr360.oneclick.entity.StaffRecord;
import com.ihr360.oneclick.exception.OneClickException;
import com.ihr360.oneclick.vo.ExcelImportResult;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *
 * @author tom
 * @date 18-1-5
 */
public class ExcelImportContext {

    private String UserId;

    /**
     * 是否第二次导入 （上一次导入没有保存）
     */
    private boolean isSecondImport;

    /**
     * 公司ID
     */
    private String companyId;

    /**
     * 功能
     */
    private OneClickTerm term;

    /**
     * 电子表格ID
     */
    private String spreadsheetId;

    /**
     * 所属月份
     */
    private Date month;

    /**
     * 电子表
     */
    private Spreadsheet spreadsheet;

    /**
     * 电子表表头
     */
    private SpreadSheetRowHeader spreadSheetRowHeader;

    /**
     * excel导入数据
     */
    private List<Map> excelRows;

    /** 电子表格固定列*/
    private Map<String, RowHeaderColumn> spreadFixedColumnMap;

    /**
     * i8n所有国际化列明所对应的固定列
     * 用于excel表头匹配
     */
    private Map<String, RowHeaderColumn> i18nFixedColumnMap;

    /**
     * 导入excel对应的固定列
     */
    private Map<String, RowHeaderColumn> excelFixedColumnMap;

    /**
     * 本次导入excel表头信息
     */
    private List<RowHeaderColumn> excelRowHeaderColumnList;

    /**
     * 导入的所有行数据
     */
    private List<SpreadsheetRow> excelSpreadsheetRowList;

    /**
     * 导入的row list
     */
    private List<StaffSpreadsheetRow> staffSpreadsheetRowList;

    /** 已经导入过的row list*/
    private List<SpreadsheetRow> existSpreadsheetRowList;

    /**
     * 新增的员工名录
     */
    private List<StaffRecord> newStaffList;

    /**
     * 公司已经存在的员工名录<staffIdentityKey, StaffRecord>
     */
    private Map<String, StaffRecord> companyAllStaffRecordMap;

    /**
     * 公司所有员工证件号 key:电话号码  value:证件号
     */
    private Map<String, String> companyAllStaffRecordIdCardNoMobileNoMap;

    /**
     * 导入结果
     */
    private ExcelImportResult excelImportResult;

    /**
     * 证件类型ID
     */
    private Map<String, IdCardType> idCardTypeMap;

    /**
     * 固定列list  map<key:别名 value:表头模型></key:别名>
     */
    private List<Map<String, RowHeaderColumn>> fixedColumns;

    /**
     * 功能ID
     */
    private String termId;

    /**
     * 微信通知状态
     */
    private Boolean weChatNotice;

    /**
     * 短信通知状态
     */
    private Boolean smsNotice;

    /**
     * 邮箱通知状态
     */
    private Boolean emailNotice;


    public String getTermId() {
        return termId;
    }

    public void setTermId(String termId) {
        this.termId = termId;
    }

    public List<Map<String, RowHeaderColumn>> getFixedColumns() {
        return fixedColumns;
    }

    public void setFixedColumns(List<Map<String, RowHeaderColumn>> fixedColumns) {
        this.fixedColumns = fixedColumns;
    }

    public ExcelImportContext() {
    }

    public ExcelImportContext(List<Map> excelRows) {
        if (excelRows != null && excelRows.size() >0) {
            this.excelRows = excelRows;
        } else {
            throw new OneClickException("one_click_term_import_excel_unknown_error", "您上传的工资表未知错误，请联系管理员！");
        }
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public OneClickTerm getTerm() {
        return term;
    }

    public void setTerm(OneClickTerm term) {
        this.term = term;
    }

    public String getSpreadsheetId() {
        return spreadsheetId;
    }

    public void setSpreadsheetId(String spreadsheetId) {
        this.spreadsheetId = spreadsheetId;
    }

    public Spreadsheet getSpreadsheet() {
        return spreadsheet;
    }

    public void setSpreadsheet(Spreadsheet spreadsheet) {
        this.spreadsheet = spreadsheet;
    }

    public Map<String, RowHeaderColumn> getI18nFixedColumnMap() {
        return i18nFixedColumnMap;
    }

    public void setI18nFixedColumnMap(Map<String, RowHeaderColumn> i18nFixedColumnMap) {
        this.i18nFixedColumnMap = i18nFixedColumnMap;
    }

    public List<RowHeaderColumn> getExcelRowHeaderColumnList() {
        return excelRowHeaderColumnList;
    }

    public void setExcelRowHeaderColumnList(List<RowHeaderColumn> excelRowHeaderColumnList) {
        this.excelRowHeaderColumnList = excelRowHeaderColumnList;
    }

    public List<Map> getExcelRows() {
        return excelRows;
    }

    public SpreadSheetRowHeader getSpreadSheetRowHeader() {
        return spreadSheetRowHeader;
    }

    public void setSpreadSheetRowHeader(SpreadSheetRowHeader spreadSheetRowHeader) {
        this.spreadSheetRowHeader = spreadSheetRowHeader;
    }

    public void setExcelRows(List<Map> excelRows) {
        this.excelRows = excelRows;
    }

    public Map<String, RowHeaderColumn> getExcelFixedColumnMap() {
        return excelFixedColumnMap;
    }

    public void setExcelFixedColumnMap(Map<String, RowHeaderColumn> excelFixedColumnMap) {
        this.excelFixedColumnMap = excelFixedColumnMap;
    }

    public Map<String, RowHeaderColumn> getSpreadFixedColumnMap() {
        return spreadFixedColumnMap;
    }

    public void setSpreadFixedColumnMap(Map<String, RowHeaderColumn> spreadFixedColumnMap) {
        this.spreadFixedColumnMap = spreadFixedColumnMap;
    }

    public List<StaffSpreadsheetRow> getStaffSpreadsheetRowList() {
        return staffSpreadsheetRowList;
    }

    public void setStaffSpreadsheetRowList(List<StaffSpreadsheetRow> staffSpreadsheetRowList) {
        this.staffSpreadsheetRowList = staffSpreadsheetRowList;
    }

    public List<StaffRecord> getNewStaffList() {
        return newStaffList;
    }



    public void setNewStaffList(List<StaffRecord> newStaffList) {
        this.newStaffList = newStaffList;
    }

    public void setSpreadsheetRowCount(int rowCount) {
        getSpreadsheet().setRowCount(getSpreadsheet().getRowCount() + rowCount);
        getSpreadsheet().setUnpublishedCount(getSpreadsheet().getUnpublishedCount() + rowCount);
    }

    public void setSpreadsheetNotAllowPublishRowCount(int notAllowPublishRowCount) {
        getSpreadsheet().setNotAllowPublishCount(getSpreadsheet().getNotAllowPublishCount() + notAllowPublishRowCount);
    }

    public boolean isSpreadsheetNew(){
        return spreadsheetId == null;
    }

    public ExcelImportResult getExcelImportResult() {
        return excelImportResult;
    }

    public void setExcelImportResult(ExcelImportResult excelImportResult) {
        this.excelImportResult = excelImportResult;
    }

    public Map<String, StaffRecord> getCompanyAllStaffRecordMap() {
        return companyAllStaffRecordMap;
    }

    public void setCompanyAllStaffRecordMap(Map<String, StaffRecord> companyAllStaffRecordMap) {
        this.companyAllStaffRecordMap = companyAllStaffRecordMap;
    }

    public List<SpreadsheetRow> getExistSpreadsheetRowList() {
        return existSpreadsheetRowList;
    }

    public void setExistSpreadsheetRowList(List<SpreadsheetRow> existSpreadsheetRowList) {
        this.existSpreadsheetRowList = existSpreadsheetRowList;
    }

    public boolean isSecondImport() {
        return isSecondImport;
    }

    public void setSecondImport(boolean secondImport) {
        isSecondImport = secondImport;
    }

    public Map<String, IdCardType> getIdCardTypeMap() {
        return idCardTypeMap;
    }

    public void setIdCardTypeMap(Map<String, IdCardType> idCardTypeMap) {
        this.idCardTypeMap = idCardTypeMap;
    }

    public String getUserId() {
        return UserId;
    }

    public void setUserId(String userId) {
        UserId = userId;
    }

    public Date getMonth() {
        return month;
    }

    public void setMonth(Date month) {
        this.month = month;
    }

    public Map<String, String> getCompanyAllStaffRecordIdCardNoMobileNoMap() {
        return companyAllStaffRecordIdCardNoMobileNoMap;
    }

    public void setCompanyAllStaffRecordIdCardNoMobileNoMap(Map<String, String> companyAllStaffRecordIdCardNoMobileNoMap) {
        this.companyAllStaffRecordIdCardNoMobileNoMap = companyAllStaffRecordIdCardNoMobileNoMap;
    }

    public List<SpreadsheetRow> getExcelSpreadsheetRowList() {
        return excelSpreadsheetRowList;
    }

    public void setExcelSpreadsheetRowList(List<SpreadsheetRow> excelSpreadsheetRowList) {
        this.excelSpreadsheetRowList = excelSpreadsheetRowList;
    }

    public Boolean getWeChatNotice() { return weChatNotice; }

    public void setWeChatNotice(Boolean weChatNotice) { this.weChatNotice = weChatNotice; }

    public Boolean getSmsNotice() { return smsNotice; }

    public void setSmsNotice(Boolean smsNotice) { this.smsNotice = smsNotice; }

    public Boolean getEmailNotice() { return emailNotice; }

    public void setEmailNotice(Boolean emailNotice) { this.emailNotice = emailNotice; }
}
